package com.monitor.controller;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.monitor.entity.ErpContractComprehensive;
import com.monitor.service.ErpContractComprehensiveService;
import com.monitor.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 合同协议其他信息表 前端控制器
 * </p>
 *
 * @author LX
 * @since 2018-09-17
 */
@RestController
@RequestMapping("/erpContractComprehensive")
@Api(description="合同协议-其他")
public class ErpContractComprehensiveController {

    @Resource
    private ErpContractComprehensiveService comprehensiveService;

    @RequestMapping("/inertOrUpdateComprehensive")
    @ApiOperation("添加Or修改其他信息")
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "parentId", value = "父id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "customerCode", value = "客户编号", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "custId", value = "客户ID", required = false, dataType = "int", paramType = "query")*/
    })
    public @ResponseBody
    Result<Integer> inertOrUpdateComprehensive(ErpContractComprehensive contract) {
        Result<Integer> result=new Result<Integer>();
        try{
            result.setCount(1);
            result.setData(comprehensiveService.insertOrUpdate(contract)?1:0);
        }catch (Exception e){e.printStackTrace();}
        return result;
    }

    @RequestMapping("/getComprehensivetById")
    @ApiOperation("根据其他id获取其他信息")
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "parentId", value = "父id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "customerCode", value = "客户编号", required = false, dataType = "int", paramType = "query"),*/
            @ApiImplicitParam(name = "contractId", value = "其他ID", required = false, dataType = "int", paramType = "query")
    })
    public @ResponseBody
    Result<ErpContractComprehensive> getComprehensivetById(Integer contractId) {
        Result<ErpContractComprehensive> result=new Result<ErpContractComprehensive>();
        try{
            result.setCount(1);
            result.setData(comprehensiveService.selectById(contractId));
        }catch (Exception e){e.printStackTrace();}
        return result;
    }


    @RequestMapping("/getComprehensivetByConId")
    @ApiOperation("根据协议id获取其他信息")
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "parentId", value = "父id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "customerCode", value = "客户编号", required = false, dataType = "int", paramType = "query"),*/
            @ApiImplicitParam(name = "conId", value = "协议ID", required = false, dataType = "int", paramType = "query")
    })
    public @ResponseBody
    Result<ErpContractComprehensive> getComprehensivetByConId(Integer contractId) {
        Result<ErpContractComprehensive> result=new Result<ErpContractComprehensive>();
        try{
            result.setCount(1);
            result.setData(comprehensiveService.selectOne(new EntityWrapper<ErpContractComprehensive>().eq("contract_id",contractId)));
        }catch (Exception e){e.printStackTrace();}
        return result;
    }

    @RequestMapping("/getComprehensiveById")
    @ApiOperation("根据其他id获取其他信息")
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "parentId", value = "父id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "customerCode", value = "客户编号", required = false, dataType = "int", paramType = "query"),*/
            @ApiImplicitParam(name = "contractId", value = "其他ID", required = false, dataType = "int", paramType = "query")
    })
    public @ResponseBody
    Result<ErpContractComprehensive> getComprehensiveById(Integer contractId) {
        Result<ErpContractComprehensive> result=new Result<ErpContractComprehensive>();
        try{
            result.setCount(1);
            result.setData(comprehensiveService.selectById(contractId));
        }catch (Exception e){e.printStackTrace();}
        return result;
    }

    @RequestMapping("/removetComprehensiveById")
    @ApiOperation("根据其他id删除其他信息")
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "parentId", value = "父id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "customerCode", value = "客户编号", required = false, dataType = "int", paramType = "query"),*/
            @ApiImplicitParam(name = "contractId", value = "其他ID", required = false, dataType = "int", paramType = "query")
    })
    public @ResponseBody
    Result<Integer> removetComprehensiveById(Integer contractId) {
        Result<Integer> result=new Result<Integer>();
        try{
            result.setCount(1);
            result.setData(comprehensiveService.deleteById(contractId)?1:0);
        }catch (Exception e){e.printStackTrace();}
        return result;
    }

}

